<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="shortcut icon" href="__IMG__/favicon.ico" />
		<link rel="bookmark" href="__IMG__/favicon.ico" type="image/x-icon" 　/>
		<title>额度转化换</title>
		<link rel="stylesheet" type="text/css" href="__CSS__/mui.min.css"/>
		<link rel="stylesheet" type="text/css" href="__CSS__/common.css"/>
		<link rel="stylesheet" type="text/css" href="__CSS__/index.css"/>
		<script src="__JS__/mui.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" charset="utf-8">
	      	mui.init();
        </script>
        <style type="text/css">
        	.list_q span{
        		width: 33.33%;
        		text-align: center;
        		float: left;
        	}
        	.back_a{
        		padding: 5px 10px;
        		background: #3DCAFD;
        		color: #fff;
				border-radius: 25px;
        	}
        	.list_q span:nth-child(2){
        		color: #999;
        	}
        	select{
        		width: 60px;
        	}
        	input[type=number]{
        		width: 35%;
        		border-radius: 10px;
        		margin: 0;
        		padding: 5px;
        		height: 30px;
        		margin-right: 10%;
        		background: #F2F2F2;
        	}
        </style>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">额度转化换</h1>
		</header>
		<div class="mui-content bg_ff">
			<div class="padding_10 list_q bor_b clearfix">
				<span>幸运888</span>
				<span><i id="total">{$money}</i>元</span>
				<span><a href="javascript:void(0);" class="back_a">一键收回</a></span>
			</div>
			<div class="padding_10 list_q bor_b clearfix">
				<span>AG</span>
				<span><i id="ag_money">{$ag_money}</i>元</span>
				<span><a href="javascript:void(0);" class="back_a" onclick="do_out(1)">一键收回</a></span>
			</div>
			<div class="padding_10 list_q bor_b clearfix">
				<span>BBIN</span>
				<span><i id="bb_money">{$bb_money}</i>元</span>
				<span><a href="javascript:void(0);" class="back_a" onclick="do_out(2)">一键收回</a></span>
			</div>
			<div class="padding_5">
				<span>转入</span>
				<select  id="game">
					<option value="1" selected>AG</option>
					<option value="2">BBIN</option>
				</select>
				<input type="number" name="" id="money" value="" />
				<a href="javascript:void(0);" class="back_a" onclick="do_in()">确定</a>
			</div>
			<div class="padding_10">
				<span style="color: red">(注：转入、转出需要时间略长,请勿重复点击)</span>
			</div>
		</div>
	</body>
	<script src="__JS__/jquery-1.7.1.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="__JS__/layer.js" ></script>
	<script src="__JS__/rooms.js" ></script>
	<script type="text/javascript">
        function do_in() {
          var game = "";
          var game_id = $('#game option:selected').val();
          var money   = $('#money').val();
          if(game_id==1){
              game = "AG";
		  }else if(game_id==2){
              game = "BB";
		  }
          var looding =   layer.open({
                type: 2
                ,content: '转入中'
            });
            $.ajax({
                type: "post",
                url: "{:url('mine/money_to_game')}",
                data: {'type':1,'money':money,'game':game},
                dataType: "json",
                async: true,
                success: function(data) {
                    var ret  = data.ret;
                    var info = data.msg;
                    var msg = data.data;
                    if(ret=='200'){
                          my_error(info);
                          layer.close(looding);
                         $('#total').html(msg.money);
                       if(game_id==1){
                         $('#ag_money').html(msg.gm_money);
					   }else{
                         $('#bb_money').html(msg.gm_money);
                       }
                    }else {
                         my_error(info);
                    }
                }
            });
        }
        function do_out(game_id) {
            var game = "";
            if(game_id==1){
                var money   = $('#ag_money').html();
                game = "AG";
            }else if(game_id==2){
                var money   = $('#bb_money').html();
                game = "BB";
            }
            var looding =   layer.open({
                type: 2
                ,content: '转出中'
            });
            $.ajax({
                type: "post",
                url: "{:url('mine/money_to_game')}",
                data: {'type':2,'money':money,'game':game},
                dataType: "json",
                async: true,
                success: function(data) {
					console.log(data);
                    var ret  = data.ret;
                    var info = data.msg;
                    var msg  = data.data;
                    if(ret=='200'){
                         my_error(info);
                        layer.close(looding);
                        $('#total').html(msg.money);
                        if(game_id==1){
                            $('#ag_money').html(msg.gm_money);
                        }else{
                            $('#bb_money').html(msg.gm_money);
                        }
                    }else {
                         my_error(info);
                    }
                }
            });
        }
	</script>
</html>
